# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>
# Contributor: William Rea <sillywilly@gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=xapian-core
pkgver=1.4.23
pkgrel=1
epoch=1
pkgdesc='Open source search engine library.'
arch=('loong64' 'x86_64')
url="https://www.xapian.org/"
license=('GPL2')
makedepends=('util-linux')
depends=('bash' 'gcc-libs' 'glibc' 'zlib')
provides=('libxapian.so')
# xapian config requires libxapian.la
options=('libtool')
source=("https://oligarchy.co.uk/xapian/${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.asc})
sha512sums=('52dffc93301f99aa150dda8ecd5fb7cc7d0f2ce30e60f393b1058055ade24281af16cf5b5c0e6b08e4754e3d18c39bb5bc068b19330a294ad460ef8a6bc56380'
            'SKIP')
b2sums=('e26a9fd5e79daf553b474e3c794178df2cdcd83ce7d7a45ae112dde624d6e7add157c76fda3a333afce6103b2edaf7e3c928e78c47aa1fd19821c3c73926442f'
        'SKIP')
validpgpkeys=('08E2400FF7FE8FEDE3ACB52818147B073BAD2B07') # Olly Betts <olly@debian.org>

prepare() {
  cd "${pkgname}-${pkgver}"
  autoreconf -vfi
}

build() {
  cd "${pkgname}-${pkgver}"

  # workaround for test failure in libzim
  #   23/27 search_iterator  FAIL  0.47s  killed by signal 6 SIGABRT
  CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}

  ./configure --prefix=/usr
  make
}

check() {
  cd "${pkgname}-${pkgver}"
  make check
}

package() {
  depends+=('libuuid.so')
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -vDm 644 {AUTHORS,ChangeLog,HACKING,NEWS,README} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
